const koaRouter = require("@koa/router");
const { verifyUser, handlePassword } = require("../middleware/user.middleware");
const userController = require("../controller/user.controller");
const { verifyAuth } = require("../middleware/login.middleware");
//1.创建路由对象
const userRouter = new koaRouter({ prefix: "/klm_api/user" });
//2.定义路由中映射
//2.1用户注册接口
userRouter.post(
  "/register",
  verifyUser,
  handlePassword,
  //verifyAuth,
  userController.create
);
/**
 * @swagger
 * /users/register: #接口访问路径(拼接上之前swagger.js中的host蛇者)
 *   post: #请求方式
 *     summary: 注册  #接口信息
 *     description: 用户注册 #接口描述
 *     tags: [用户] #接口分组
 *     produces:
 *       - application/x-www-form-urlencoded
 *     security:
 *       - token: []
 *     parameters: #传递参数
 *       - name: email #参数名字
 *         description: 邮箱 #参数信息
 *         in: formData #参数存放位置formData是存放到请求体中
 *         required: true #是否是必传参数
 *         type: string #参数类型
 *       - name: code
 *         description: 验证码
 *         type: string
 *         in: formData
 *         required: true
 *       - name: password
 *         description: 密码
 *         in: formData
 *         required: true
 *         type: string
 *     responses: #返回结果
 *       200:
 *         description: 成功
 */
userRouter.get("/list", (ctx, next) => {
  ctx.body = "user list";
});
userRouter.get("/avatar/:userId", userController.showAvatarImage);
module.exports = userRouter;
